// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com).
// All rights reserved (http://jonathanmagnan.com/extension-methods-library).
// Licensed under MIT License (MIT) (http://zextensionmethods.codeplex.com/license).

using System;

#if EXTENSIONMETHODS_WITHNAMESPACE
namespace JHSoft.Extension.ExtensionMethods
{
#endif
#if EXTENSIONMETHODS_INTERNAL
    internal static partial class BooleanExtensions
#else
    public static partial class BooleanExtensions
#endif
    {
        /// <summary>
        ///     A bool extension method that execute an Action if the value is false.
        /// </summary>
        /// <param name="this">The @this to act on.</param>
        /// <param name="action">The action to execute.</param>
        /// <example>
        ///     <code>
        ///           using Microsoft.VisualStudio.TestTools.UnitTesting;
        ///           using JHSoft.Extension.ExtensionMethods;
        ///           
        ///           namespace ExtensionMethods.Examples
        ///           {
        ///               [TestClass]
        ///               public class System_Boolean_IfFalse
        ///               {
        ///                   [TestMethod]
        ///                   public void IfFalse()
        ///                   {
        ///                       // Variables
        ///                       string value1 = &quot;&quot;;
        ///                       string value2 = &quot;&quot;;
        ///           
        ///                       // Type
        ///                       const bool conditionTrue = true;
        ///                       const bool conditionFalse = false;
        ///           
        ///                       // Examples
        ///                       conditionTrue.IfFalse(() =&gt; value1 = &quot;FizzBuzz&quot;); // value1 = &quot;&quot;;
        ///                       conditionFalse.IfFalse(() =&gt; value2 = &quot;FizzBuzz&quot;); // value2 = &quot;FizzBuzz&quot;;
        ///           
        ///                       // Unit Test
        ///                       Assert.AreEqual(&quot;&quot;, value1);
        ///                       Assert.AreEqual(&quot;FizzBuzz&quot;, value2);
        ///                   }
        ///               }
        ///           }
        ///     </code>
        /// </example>
        public static void IfFalse(this bool @this, Action action)
        {
            if (!@this)
            {
                action();
            }
        }
    }
#if EXTENSIONMETHODS_WITHNAMESPACE
}
#endif